package listener;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JTextField;

import config.Config;

import ui.ClassIpUI;
import ui.MainUI;
import util.Java_JDBC;

/**
 * 实现接口ActionListener
 * @author wj
 *
 */
public class ClassIPListener implements ActionListener{
//	private JTextField className;
	private ClassIpUI classIpUI;
	private JButton jb1, jb2;
	public ClassIPListener(ClassIpUI classIpUI) {
		this.classIpUI = classIpUI;
//		this.className = classIpUI.className;
		this.jb1 = classIpUI.jb1;
		this.jb2 = classIpUI.jb2;
	}
	
	/**
	 * 对输入的信息进行判断
	 * 输出结果
	 */
	public void actionPerformed(ActionEvent e){
		if(e.getSource() == jb1) {
//			Config.className = className.getText();
//			System.out.println("Config.className:  "+Config.className);
			try {
				Config.totalNumber = new Java_JDBC().searchStudentCount(Config.className);
				Config.signNumber = new Java_JDBC().searchSignCount(Config.className);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
			classIpUI.dispose();
			new MainUI().setVisible(true);
		}else if(e.getSource() == jb2){
			classIpUI.dispose();
			System.exit(0); 
		}
	}
}
